package com.qiyang.es.entity;

import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.bson.types.ObjectId;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

/**
 * Created on 2018/6/29.
 *
 * @author sehuaqi.
 * 描述：
 * indexName 索引名称 可以理解为数据库名 必须为小写 不然会报
 * type 类型 可以理解为表名
 */
@Data
@Document(indexName = "demoindex", type = "goods")
public class GoodsInfo implements Serializable {

    private String id;

    private String name;

    private String description;

    public GoodsInfo(String id, String name, String description) {
        this.id = id;
        if (StringUtils.isEmpty(this.id)) {
            this.id = ObjectId.get().toString();
        }
        this.name = name;
        this.description = description;
    }

    public GoodsInfo() {

    }
}
